﻿var baseUrl = getBaseplatformPort();
$(function () {
    //获取URL地址参数
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) { return pair[1]; }
        }
        return (false);
    }
    var id = getQueryVariable("id");
    $('.title-color').html();
    var html = '<img src="/img/news.png"> &nbsp;<a id="homeBtn" href="home.html" target="_self">首页</a> > <a href="News_List.html" >新闻中心</a> ';
    $('.title-color').html(html);
    GetNews_List_ID(id);
     $('#homeBtn').on('click', function () {
         if (parent.window.$('#homeIframe').length && parent.window.$('#homeBtn').length) {
             parent.window.$('#homeBtn').click();
         }
     });
    //根据id查新闻
    function GetNews_Platform_List_id(id) {
        $('#news_Content').html();
        var data = {
            //mtype: "GetNews_Platform_List_id",
            id: id
        }
        $.ajax({
            type: "post",
            async: false,
            url: baseUrl + "news/getNewsListById",
            //url: "/BaseAshx/NewsManage/News_List.ashx",
            data: data,
            datatype: "json",
            success: function (res) {
                res = JSON.parse(res)
                if (res.code == 200) {
                    var html = "";
                    var table = res.data.table;
                    if (table != null) {
                        html += '<p class="news_Content_title">' + table[0].TITLE + '</p>' +
                       ' <p class="news_Content_body">' +
                       '<span>来源：' + table[0].SOURCE + '</span>' +
                       '<span>作者：' + table[0].AUTHOR + '</span>' +
                       '<span>发布时间：' + table[0].CREATETIME + '</span></p>' +
                       '<div class="news_Content_content">' + table[0].CLOB + '</div>';
                        $('#news_Content').html(html);
                    } else {
                        layui.layer.msg(res.msg, {
                            shade: 0.3,
                            time: 1000 // 1秒关闭
                        });
                        return;
                    }
                   
                } else {
                    layui.layer.msg(res.msg, {
                        shade: 0.3,
                        time: 1000 // 1秒关闭
                    });
                    return;
                }
            }
        })
    }
    function GetNews_List_ID(id) {
        $('#news_Content').html();
        var data = {
            //mtype: "GetNews_List_ID",
            id: id
        }
        $.ajax({
            type: "post",
            async: false,
            url: baseUrl + "news/getNewsListById",
            //url: "/BaseAshx/NewsManage/News_List.ashx",
            data: data,
            datatype: "json",
            success: function (res) {
                res = JSON.parse(res)
                if (res.code == 200) {
                    var html = "";
                    var table = res.data.table;
                    if (table != null) {
                        html += '<p class="news_Content_title">' + table[0].TITLE + '</p>' +
                       ' <p class="news_Content_body">' +
                       '<span>来源：' + table[0].SOURCE + '</span>' +
                       '<span>作者：' + table[0].AUTHOR + '</span>' +
                       '<span>发布时间：' + table[0].CREATETIME + '</span></p>' +
                       '<div class="news_Content_content">' + table[0].CLOB + '</div>';
                        $('#news_Content').html(html);
                    } else {
                        layui.layer.msg(res.msg, {
                            shade: 0.3,
                            time: 1000 // 1秒关闭
                        });
                        return;
                    }

                } else {
                    layui.layer.msg(res.msg, {
                        shade: 0.3,
                        time: 1000 // 1秒关闭
                    });
                    return;
                }
            }
        })
    }
})